package StudyCode.summary.zipfile;

import java.io.*;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ReadFileInStringUsingBufferedInputStream {
	public static void main(String[] args) {

		File file = new File("E:/Copy/2.txt");
		BufferedInputStream bin = null;

		try {
			FileInputStream fin = new FileInputStream(file);

			bin = new BufferedInputStream(fin);

			byte[] contents = new byte[1024];

			int bytesRead = 0;
			String strFileContents;

			while ((bytesRead = bin.read(contents)) != -1) {

				strFileContents = new String(contents, 0, bytesRead);
				System.out.print(strFileContents);
			}

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException ioe) {
			ioe.printStackTrace();
		} finally {
			try {
				if (bin != null)
					bin.close();
			} catch (IOException ioe) {
				ioe.printStackTrace();
			}

		}
	}

}
